//
//  ConfirmOrderCell.m
//  OrderSeat
//
//  Created by wangwei on 13-10-14.
//  Copyright (c) 2013年 wangwei. All rights reserved.
//

#import "ConfirmOrderCell.h"

@interface ConfirmOrderCell ()

@end

@implementation ConfirmOrderCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)setContent:(NSMutableDictionary*)dictionary
{
    self.dictionary = dictionary;
    NSString *orderTime = [dictionary objectForKey:@"order_time"];
    NSString *dinner = [dictionary objectForKey:@"zaowan"];
    NSString *datetime = [NSString stringWithFormat:@"%@ %@", orderTime,dinner];
    
    _seatNameLabel.text = [dictionary objectForKey:@"zname"];
    _orderTimeLabel.text = datetime;
    
    self.selectedBtn.selected = [[dictionary objectForKey:@"selected"] intValue] == 1;
    
    [_view drawBorder];
    [self addTarget:self action:@selector(selectedAction:)];
}

- (IBAction)selectedAction:(id)sender
{
    int selected = [[self.dictionary objectForKey:@"selected"] intValue];
    selected = selected == 0 ? 1 : 0;
    [self.dictionary setObject:[NSString stringWithFormat:@"%d",selected] forKey:@"selected"];
    
    self.selectedBtn.selected = selected == 1;
}

@end
